<?php function spaceToNbsp($text) { return str_replace(array(' ', "\t"), array('&nbsp; ', '&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; '), $text); } ?>
<?php echo $this->error($this); ?>
<div class="usvn_info">
  <h1><?php echo T_('Commit').': '.$this->commit ?></h1>
  <table style="width: 100%;">
    <tr>
      <td><?php echo T_('Author'); ?>:</td>
      <td><?php echo $this->author ?></td>
    </tr>
    <tr>
      <td><?php echo T_('Date'); ?>:</td>
      <td><?php echo $this->date ?></td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><?php echo T_('Files'); ?>:</td>
      <td>
        <?php foreach ($this->diff as $file => $diff): ?>
        <a href="#<?php echo htmlentities($file) ?>"><?php echo htmlentities($file); ?></a><br />
        <?php endforeach; ?>
      </td>
    </tr>
    <tr>
      <td style="vertical-align: top;"><?php echo T_('Comment'); ?>:</td>
      <td><?php echo USVN_SVNLog::formatComment($this->log); ?></td>
    </tr>
  </table>
</div>
<div style="font-family:monospace;">
  <?php foreach ($this->diff as $file => $diff): ?>
    <table border="0" cellspacing="1px" cellpadding="0" width="100%" style="padding: 2px;">
      <tr height="30px">
        <th style="background-color: #EEEEEE;" width="30px;">r<?php echo $this->base ?></th>
        <th style="background-color: #EEEEEE;" width="30px;">r<?php echo $this->commit ?></th>
        <th align="left" style="background-color: #EEEEEE; padding-left: 20px;">
          <a name="<?php echo htmlentities($file); ?>" href="<?php echo $this->url(array('project' => $this->project->name, 'action' => 'show'), 'project')."/".str_replace('%2F', '/', urlencode(trim($file))).'?rev='.$this->commit ?>"><?php echo htmlentities($file); ?></a>
        </th>
      </tr>
      <?php $i = NULL ?>
      <?php foreach ($diff as $d): ?>
        <?php if ($i !== NULL): ?>
          <tr>
            <td style="background-color: #EEEEEE;">&nbsp;</td>
            <td style="background-color: #EEEEEE;">&nbsp;</td>
            <td style="background-color: #EEEEEE;">&nbsp;</td>
          </tr>
        <?php endif; ?>
        <?php for ($i = 0, $basei = $d[$this->base]['begin'], $commiti = $d[$this->commit]['begin']; TRUE; ++$i): ?>
          <?php if (isset($d[$this->base]['content'][$i])): ?>
            <tr>
              <td style="background-color: #EEEEEE;"><?php echo ($basei++); ?></td>
	          <td style="background-color: #EEEEEE;">&nbsp;</td>
	          <td style="background-color: #FFDDDD;">
	            <span><?php echo spaceToNbsp($d[$this->base]['content'][$i]); ?></span>
	          </td>
	        </tr>
          <?php elseif (isset($d[$this->commit]['content'][$i])): ?>
            <tr>
              <td style="background-color: #EEEEEE;">&nbsp;</td>
	          <td style="background-color: #EEEEEE;"><?php echo ($commiti++); ?></td>
	          <td style="background-color: #DDFFDD;">
	            <span><?php echo spaceToNbsp($d[$this->commit]['content'][$i]); ?></span>
	          </td>
	        </tr>
          <?php elseif (isset($d['common'][$i])): ?>
            <tr>
              <td style="background-color: #EEEEEE;"><?php echo ($basei++); ?></td>
	          <td style="background-color: #EEEEEE;"><?php echo ($commiti++); ?></td>
	          <td><span><?php echo spaceToNbsp($d['common'][$i]); ?></span></td>
	        </tr>
          <?php else: ?>
            <?php break ?>
          <?php endif; ?>
        <?php endfor ?>
      <?php endforeach; ?>
    </table>
    <br />
  <?php endforeach; ?>
</div>
